*********************************************************************************
/*    Create time series plot for revenue, wages, and audit probability		*/
*********************************************************************************
clear all

* File paths
local datapath "${mvpf_audits}/data/cleaned" 
local graphpath "${graphpath}" 
local dofilepath "${mvpf_audits}/code/prep" 

* years to keep
local min_yr = ${min_yr}
local max_yr = ${max_yr}

* Version of fig to produce 
global version ${version} // paper or slides

* Other formatting
if "${version}" == "slides" {
	global title "title(" ", size(vhuge))"
	global img wmf
	graph set window fontface "Arial"
	global title "title(" ", size(vhuge))"
	global axis_size "" //xsize(6.5) ysize(4)" // makes figure wider
}

else if "${version}" == "paper" {
	global title "title("")"
	global img pdf
	graph set window fontface "LMRoman10-Regular"
	global title " "
	global axis_size " " // makes figure wider
}

* Audit type
local 1 = "ops"
if "`1'" == "nrp" local t = "nrp"
if "`1'" == "ops" local t = "ops"
if "`1'" == "both" local t = "ops nrp"

local types "`t'"

use "${mvpf_audits}/data/figures_rep/ap3_a_b.dta", clear
	
/*------------------------------------------------------------------------------
Plot audit rates by income percentile
------------------------------------------------------------------------------*/
	tw  (connected corr_rate_round tpi_pctl if tpi_pctl>0, lc(gs4) mc(gs4) ///
		ytitle("Correspondence Audit Rate 2010-2014 (%)")  ///
		ylabel(, nogrid format(%09.1fc) )) ///	
		, ///
		legend(off) ///
		${title} ${axis_size} ///
		xscale(r()) xtitle("TPI percentile group") ///
		xlabel(1(1)22, value labsize(small) tl(.5) nogrid angle(45) )
	graph export "`graphpath'/connected_audit_rates_corr.wmf", as(wmf) replace
	

/*------------------------------------------------------------------------------
Figure: Line plot of hours worked and wages by year
------------------------------------------------------------------------------*/	
	* exam type pooled
	if "`type'" == "nrp"{
		local i = 4
	}
	
	if "`type'" == "ops"{
		local i = 1
	}
	

	* set y-axis label, title, and figure name
	local ylab = "Average value"
	

	* Preferences 
	local symbsize medsmall
	local textsize vsmall
	

	*** Subgroup figure
	local fig_name = "connected_hours_wages_inc"
	
	local lb = 20
	local ub = 50 // round(`max', 100)
	local int = 6 // (`ub' - `lb')/5	


	
	local lb_f : di %02.1f `lb'
	local ub_f : di %02.1f `ub'
	
	global oh_color = "240 128 128"

	tw  (connected hours_future ${inc}_pctl if inrange(${inc}_pctl, 1, 22), ///
		mcolor("${oh_color}") lc("${oh_color}") msymbol(O) msize(`symbsize')) ///
		(connected wage ${inc}_pctl if inrange(${inc}_pctl, 1, 22), ///
		mcolor(cranberry) lc(cranberry) msymbol(T) msize(small)) ///
		, ///
		text(27 10 "Auditor wage rate ($/hour)") ///
		text(5 10 "Hours per audit") ///
		ylabel(, nogrid format(%9.0fc)) yscale(r()) ///
		ytitle("`ylab'") xtitle("${xtitle}")   ///
		///legend(order(2 1)  lab(1 "Hours per audit") lab(2 "Auditor Wage ($/hour)") ///
		///ring(0) pos(11) col(1) symxsize(*3.5) region(lcolor())) ///
		legend(off) ///
		${title} ${axis_size} ///
		xscale(r()) xtitle("Year") ///
		xlabel(1(1)22, value labsize(small) tl(.5) nogrid angle(45) )
	graph export "`graphpath'/`fig_name'_corr.wmf", as(wmf) replace
*/	



		
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
